local _M = {}
local router = _M

local json = require 'cjson.safe'
local http = require 'resty.http'
local conf = require 'conf'

local function doMultiReq(nut)
    local url = conf.archon.url
    local timeout = conf.archon.timeout

    local httpc = http.new()
    httpc:set_timeout(timeout)

    local param = {
        adspot = {
            support_creative_type = {1}
        }
    }

    local req = {
        method = 'POST',
        path = '/dsp',
        body = json.encode(param),
        headers = {["Content-Type"] = "application/json"}
    }

    local res, err = httpc:request_uri(url, req)
    ngx.log(ngx.ERR, 'test: ', json.encode(res.body))

    nut.http_rsp.body = res.body
    nut.http_rsp.code = ngx.HTTP_OK
end

function _M.doRouter(nut)
    -- do http req
    doMultiReq(nut)
end


return router
